package com.jeecms.edu.servlet;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.jeecms.common.web.ResponseUtils;
import com.jeecms.edu.entity.SchoolInformation;

/**
 * 保存小学详细信息
 */
@WebServlet("/SaveSchoolDetail")
public class SaveSchoolDetail extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String schoolname=request.getParameter("schoolname");
		String enrollment=SchoolInformation.checkSchoolEnrollment(schoolname);
		request.getSession().getServletContext().setAttribute("enrollment", enrollment);
		String schoolurl=SchoolInformation.checkSchoolUrl(schoolname);
		request.getSession().getServletContext().setAttribute("schoolurl", schoolurl);
		Map map=SchoolInformation.checkSchoolDetail(schoolname);
//		System.out.println(schoolname+map);
		JSONObject jsonObject=new JSONObject();
		if (null!=map) {
			request.getSession().getServletContext().setAttribute("schooldetail", map);
			jsonObject.put("report", "0");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json); 
		}else{
			jsonObject.put("report", "1");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json);
		}
	}

}
